package com.chinastock.demo.controller;

import com.alibaba.fastjson.JSON;
import com.chinastock.communication.BaseResponse;
import com.chinastock.demo.vo.BizLogVo;
import com.chinastock.log.Biz;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import com.chinastock.log.LogName;
import com.chinastock.model.AppMessage;

/**
 * @author wangzhendong
 */
@RestController
@Api(tags = {"BizLog测试"})
public class BizLogController {

    @RequestMapping(path = "/bizLogJson", method = RequestMethod.POST)
    @ApiOperation(value = "返回信息", notes = "根据请求参数，返回请求信息")
    @ApiImplicitParam(name = "request", value = "请求", dataType = "com.chinastock.demo.vo.BizLogVo")
    @Biz
    public BaseResponse<String> BizLogController(@RequestBody BizLogVo request) throws Exception{
        BaseResponse<String> response = new BaseResponse<String>(true, "200", "Test response for bizLogJson");
        return response;
    }

    @RequestMapping(path = "/bizLogText", method = RequestMethod.POST)
    @ApiOperation(value = "返回信息", notes = "根据请求参数，返回请求信息")
    @Biz
    public BaseResponse<String> BizLogController(@RequestBody String request) throws Exception{
        BaseResponse<String> response = new BaseResponse<String>(true, "200", "Test response for bizLogText");
        return response;
    }

    @RequestMapping(path = "/bizLogFile", method = RequestMethod.POST)
    @ApiOperation(value = "返回信息", notes = "根据请求参数，返回请求信息")
    @Biz
    public BaseResponse<String> BizLogController(@RequestParam("file") MultipartFile file) throws Exception{
        BaseResponse<String> response = new BaseResponse<String>(true, "200", "Test response for bizLogFile");
        return response;
    }
    @RequestMapping(path = "/CustLog", method = RequestMethod.POST)
    @ApiOperation(value = "返回信息", notes = "根据请求参数，返回请求信息")
    @Biz
    public BaseResponse<String>CustLogController(@RequestBody JSON request) throws Exception{
        BaseResponse<String> response = new BaseResponse<String>(true, "200", "Test response for CustLog");
        return response;
    }
    @RequestMapping(path = "/ExceptionLog", method = RequestMethod.POST)
    @ApiOperation(value = "返回信息", notes = "根据请求参数，返回请求信息")
    @Biz
    public BaseResponse<String> ExceptionLogController(@RequestBody JSON request) throws Exception{
        Exception testException = new Exception("test exception of ExceptionLog");
        throw testException;
    }
    @RequestMapping(path = "/PerformanceLog", method = RequestMethod.POST)
    @ApiOperation(value = "返回信息", notes = "根据请求参数，返回请求信息")
    @Biz
    public BaseResponse<String> PerformanceLog(@RequestBody JSON request) throws Exception{
        BaseResponse<String> response = new BaseResponse<String>(true, "200", "Test response for PerformanceLog");
        return response;
    }
}
